//
//  UserHeadView.m
//  WYModel
//
//  Created by ios on 2017/3/10.
//  Copyright © 2017年 Wy. All rights reserved.
//

#import "UserHeadView.h"

@interface UserHeadView ()
@property(nonatomic,strong) UIImageView *bgImageView;
@property(nonatomic,strong) UIImageView *headImageView;
@property(nonatomic,strong) UILabel     *nickNameLabel;


@end

@implementation UserHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self ) {
        
        [self configView];
    }
    return self;
}

-(void)setUserImage:(NSString *)imgUrl nickName:(NSString *)name{
    
//    [_bgImageView sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
//    
//    [_headImageView sd_setImageWithURL:[NSURL URLWithString:imgUrl]];
//    
//    _nickNameLabel.text = name;
    
}

-(void)configView{
    CGFloat viewW = self.frame.size.width;
    CGFloat viewH = self.frame.size.height;
    
    _bgImageView               = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, viewW, viewH)];
    _bgImageView.clipsToBounds = YES;
    _bgImageView.contentMode   = UIViewContentModeScaleAspectFill;
    _bgImageView.image = [UIImage imageNamed:@"userheader.jpg"];
    
    
    
    [self addSubview:_bgImageView];
    
    _headImageView     = [[UIImageView alloc] initWithFrame:CGRectMake(viewW/2-35, viewH/2-35, 70, 70)];
    _headImageView.layer.cornerRadius  = 35;
    _headImageView.layer.borderWidth   = 2.0;
    _headImageView.layer.borderColor   = [UIColor whiteColor].CGColor;
    _headImageView.layer.masksToBounds = YES;
    _headImageView.image = [UIImage imageNamed:@"userheader.jpg"];
    
    [self addSubview:_headImageView];
    
    _nickNameLabel    = [[UILabel alloc] initWithFrame:CGRectMake(0, viewH/2+40, viewW, 21)];
    _nickNameLabel.textColor  = [UIColor whiteColor];
    _nickNameLabel.font       = [UIFont wyNormalFot:15];
    _nickNameLabel.textAlignment  = NSTextAlignmentCenter;
    
    [self addSubview:_nickNameLabel];
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
